package com.cndatacom.eweb.service.impl;

import java.util.List;

import com.cndatacom.eweb.dao.IRightControlDao;
import com.cndatacom.eweb.model.RightControl;
import com.cndatacom.eweb.service.IRightControlService;

@SuppressWarnings("unchecked")
public class RightControlService implements IRightControlService {

	private IRightControlDao rightControlDao;
	
	public void addOrUpdatePermission(String rightType, int rightOwnerId, int moduleId, int permission, boolean yes) {
		rightControlDao.addOrUpdatePermission(rightType, rightOwnerId, moduleId, permission, yes);
	}

	public void addOrUpdateRoleInherit(int userId, int moduleId, boolean yes) {
		rightControlDao.addOrUpdateRoleInherit(userId, moduleId, yes);
	}
	
	public void addOrUpdateOrgInherit(int userId, int moduleId, boolean yes) {
		rightControlDao.addOrUpdateOrgInherit(userId, moduleId, yes);
	}

	public void deletePermission(String rightType, int rightOwnerId, int moduleId) {
		rightControlDao.deletePermission(rightType, rightOwnerId, moduleId);
	}

	public RightControl getRightControl(String rightType, int rightOwnerId, int moduleId) {
		return rightControlDao.findRightControl(rightType, rightOwnerId, moduleId);
	}

	public boolean hasPermission(int userId, int moduleId, int permission) {
		return rightControlDao.hasPermission(userId, moduleId, permission);
	}

	public IRightControlDao getRightControlDao() {
		return rightControlDao;
	}
	public void setRightControlDao(IRightControlDao rightControlDao) {
		this.rightControlDao = rightControlDao;
	}

	public List getAllCanViewModules(int userId) {
		return rightControlDao.getAllCanViewModules(userId);
	}

	public boolean deleteRightControlByModuleId(int moduleId) {
		return rightControlDao.deleteRightControlByModuleId(moduleId);
	}

	public boolean deleteRightControlByOrgId(int orgId) {
		return rightControlDao.deleteRightControlByOrgId(orgId);
	}

	public boolean deleteRightControlByOwnertypeAndOwnerid(int rightOwnerId) {
		return rightControlDao.deleteRightControlByOwnertypeAndOwnerid(rightOwnerId);
	}

	public boolean deleteRightControlByRoleId(int roleId) {
		return rightControlDao.deleteRightControlByRoleId(roleId);
	}


}

